package com.itkeien.streamprogramproject.simpStream;

import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ParallelStream {
    public static void main(String[] args) {


        Set collect = Collections.singleton(Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
                .parallel()
                .collect(
                        Collector.of(
                                () -> new HashSet<>(),
                                (set, item) -> set.add(item),
                                (set1, set2) -> {
                                    set1.addAll(set2);
                                    return set1;
                                },
                                set -> set,
                                Collector.Characteristics.IDENTITY_FINISH
//                                Collector.Characteristics.CONCURRENT,
//                                Collector.Characteristics.UNORDERED
                        )
                ));
        System.out.println(collect);


    }
}
